/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DataViewer.java
 *
 * Created on Sep 26, 2011, 3:55:37 PM
 */
package bootsie;

import java.util.Iterator;

/**
 *
 * @author John Foster
 */
public class DataViewer extends javax.swing.JFrame {

    /** Creates new form DataViewer */
    public DataViewer() {
        initComponents();
    }
    
    private static DataViewer dataViewer;
    
    public static DataViewer getViewer(){
        if (dataViewer == null) {
            dataViewer = new DataViewer();
        }
        return dataViewer;
    }
    
    public void showDataMatrix(PopulationMatrixModel d){
        javax.swing.JTextArea t = jTextArea1;
        t.setText("");
        //spool out data matrix
        t.append("Population name: " + d.popName + "\n");
        t.append(d.getSize() + " samples\n");
        t.append(new Integer(d.getLength()).toString() + " loci\n");
        t.append("Bootstrap setting = " + d.numBootstraps + " bootstraps.\n");
        Iterator<DataSample> it = d.iterator();
        while (it.hasNext()){
            DataSample s = it.next();
            t.append(s.toString());
            t.append("\n");
        }
        this.setVisible(true);
        this.toFront();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(bootsie.BootsieApp.class).getContext().getResourceMap(DataViewer.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jScrollPane1.setName("jScrollPane1"); // NOI18N
        jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 200));

        jTextArea1.setColumns(20);
        jTextArea1.setFont(resourceMap.getFont("TextArea.font")); // NOI18N
        jTextArea1.setRows(5);
        jTextArea1.setAutoscrolls(false);
        jTextArea1.setName("TextArea"); // NOI18N
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 592, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables
}
